package com.thx.information.service;

import com.thx.common.service.BaseManager;
import com.thx.information.dao.CommentLogDao;
import com.thx.information.model.InfoCommentLog;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class CommentLogService extends BaseManager<InfoCommentLog> {

  private static final Logger logger = LoggerFactory.getLogger(CommentLogService.class);

  @Autowired
  private CommentLogDao commonLogDao;


  public List<InfoCommentLog> queryAll(Long enterpriseId, Long infoId) {
    return commonLogDao.queryAll(enterpriseId, infoId);
  }

  public Integer queryCount(Long enterpriseId, Long infoId) {
    return this.commonLogDao.queryCount(enterpriseId, infoId);
  }

  /**
   * 根据新闻id分页查询所有评论，并按评论时间倒排序.
   * 
   * @param infoId 新闻id,不能为空
   * @return 分页新闻评论信息列表
   */
  public List<InfoCommentLog> findByInfoId(Long infoId) {
    return commonLogDao.findByInfoId(infoId);
  }

  /**
   * 根据新闻id查询所有评论，并按评论时间倒排序.
   * 
   * @param infoId 新闻id,不能为空
   * @return 新闻评论信息列表
   */
  public List<InfoCommentLog> findAllByInfoId(Long infoId) {
    return commonLogDao.findAllByInfoId(infoId);
  }
  
  /**
   * 根据消息id查询该消息评论数量
   * @param infoId 新闻id,不能为空
   * @return 消息评论数量
   */
  public int queryCountByInfoId(Long infoId) {
    return commonLogDao.queryCountByInfoId(infoId);
  }
}
